package com.yztstudy.dto;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

/**
 * 返回给前端的数据结构
 */

@Data
@NoArgsConstructor
@AllArgsConstructor
public class Result {
    private Boolean success; //业务是否执行成功
    private String errorMsg; //错误码
    private Object data; //数据
    private Long total; //数据的数量

    public static Result ok(){
        return new Result(true, null, null, null);
    }
    public static Result ok(Object data){
        return new Result(true, null, data, null);
    }
    public static Result ok(List<?> data, Long total){
        return new Result(true, null, data, total);
    }
    public static Result fail(String errorMsg){
        return new Result(false, errorMsg, null, null);
    }
}
